package it.blueocean.acanto.web.platform.components.repeaters;

import java.io.Serializable;
import java.util.List;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.IAjaxIndicatorAware;
import org.apache.wicket.extensions.ajax.markup.html.AjaxIndicatorAppender;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;

@SuppressWarnings("unchecked")
public class DropDownChoiceWithAjaxIndicator extends DropDownChoice implements IAjaxIndicatorAware
{
	private static final long serialVersionUID = -7293019476392750331L;

	private final AjaxIndicatorAppender indicatorAppender = new AjaxIndicatorAppender();

	public DropDownChoiceWithAjaxIndicator(String id, IModel choices, IChoiceRenderer renderer,
			MarkupContainer markupContainer)
	{
		super(id, choices, renderer);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, IModel model, IModel choices, IChoiceRenderer renderer,
			MarkupContainer markupContainer)
	{
		super(id, model, choices, renderer);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, IModel model, IModel choices, MarkupContainer markupContainer)
	{
		super(id, model, choices);
		init(markupContainer);
	}
	
	public DropDownChoiceWithAjaxIndicator(String id, IModel model, List<Serializable> data, IChoiceRenderer renderer,
			MarkupContainer markupContainer)
	{
		super(id, model, data, renderer);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, IModel model, List<Serializable> choices,
			MarkupContainer markupContainer)
	{
		super(id, model, choices);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, IModel choices, MarkupContainer markupContainer)
	{
		super(id, choices);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, List<Serializable> data, IChoiceRenderer renderer,
			MarkupContainer markupContainer)
	{
		super(id, data, renderer);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, List<Serializable> choices, MarkupContainer markupContainer)
	{
		super(id, choices);
		init(markupContainer);
	}

	public DropDownChoiceWithAjaxIndicator(String id, MarkupContainer markupContainer)
	{
		super(id);
		init(markupContainer);
	}

	public String getAjaxIndicatorMarkupId()
	{
		return indicatorAppender.getMarkupId();
	}

	private void init(MarkupContainer markupContainer)
	{
		add(indicatorAppender);
	}

}
